home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / JORF21_2.ZIP / MAILLIST.J < prev    next >
Text File  |  1993-07-05  |  16KB  |  430 lines

  1. Class:Contact           | Class definition for a Contact structure
  2.   Index:FullName        | Full name
  3.   Index:Company         | Company
  4.   Index:WorkPhone       | Work Phone
  5.   Index:LastName        | Last Name
  6.   Index:ZipCode         | Zip Code
  7.   Addr1                 | Address
  8.   Addr2
  9.   Addr3
  10.   HomePhone             | Home Phone
  11.   WorkPhone
  12.   FaxPhone
  13.   Birthday
  14.   Anniversary
  15.   Dear
  16.   Comment
  17.   Notes                 | Notepad
  18.   Type
  19.  
  20. MailList:Start                     | Little Mail List Program
  21.   New (Contact:Con)                | Create Contact Structure
  22.   Jorf:File ("CONTACT.JCM",Here)   | Set Database File to CONTACT.JCM
  23.   Event:Add ("MailKey","Key",Here) | Set MailKey as a keystroke handler
  24.   Mem:Ptr->IndexName = "FullName"  | Index Name
  25.  
  26.   | The main screen with menu options
  27.   Win:Add ("Josephine's Mail List Manager", 2, 2, 22, 78, Here)
  28.     Menu:"&File"
  29.       Menu:"&About            "  Action:"MailList:About"
  30.       Menu:
  31.       Menu:"&Rebuild        ",   Action:"Jorf:Rebuild"
  32.       Menu:
  33.       Menu:"E&xit        Alt-X", Action:"Kbd:Put('Esc_Key')"
  34.  
  35.     Menu:"&Edit"
  36.       Menu:"&Add     Alt-A", Action:"MailList:Add(Con)"    HotKey:"Alt_A_Key"
  37.       Menu:"&Change  Alt-C", Action:"MailList:Change(Con)"
  38.       Menu:"&Delete  Alt-D", Action:"MailList:Delete(Con)" HotKey:"Alt_D_Key"
  39.  
  40.     Menu:"&Search",
  41.       Menu:"&Name       ",  Action:"MailList:KeySearch (Con, 'FullName' )
  42.       Menu:"&Company    ",  Action:"MailList:KeySearch (Con, 'Company'  )
  43.       Menu:"&Last Name  ",  Action:"MailList:KeySearch (Con, 'LastName' )
  44.       Menu:"&Phone      ",  Action:"MailList:KeySearch (Con, 'WorkPhone')
  45.       Menu:"&Zip        ",  Action:"MailList:KeySearch (Con, 'ZipCode'  )
  46.  
  47.     Menu:"&Reports"
  48.       Menu:"&Mail List    ", Action:"MailList:List()"
  49.       Menu:"&This Contact ", Action:"MailList:PrintData(Con)"
  50.       Menu:"&Lotsa Labels ", Action:"MailList:ContinLabels(Con,'All')"
  51.       Menu:"&One Label",     Action:"MailList:ContinLabels(Con,'One')"
  52.  
  53.     InpBefore:"MailList:Lock(Con)"
  54.     Group:"&Browse List", Row:1 Col:41, Len:6, Wid:36
  55.     List:""
  56.       Field:"Con"
  57.       Next:"MailList:NextRecord(Con,'Next')"
  58.       Prev:"MailList:NextRecord(Con,'Prev')"
  59.       Show:"MailList:Show(Con)"
  60.       Before:"MailList:Write()"
  61.       Display:"(Mem:Ptr->Locked==Null)"
  62.  
  63.     Group:"&Contact Name and Address", Row:1, Col:1, Wid:38, Len:6
  64.     Input:"Name   ",    Wid:30, Field:"Con->FullName"
  65.       After:"MailList:SplitName(Con)"
  66.     Input:"Company", Wid:30,    Field:"Con->Company"
  67.     Input:"Address", Wid:30,    Field:"Con->Addr1"
  68.     Input:"       ", Wid:30,    Field:"Con->Addr2"
  69.     Input:"       ", Wid:30,    Field:"Con->Addr3"
  70.       After:"MailList:ZipCode(Con)"
  71.  
  72.     Group:"Mail List Fields"
  73.       Row:9  Col:1  Len:11  Wid:76
  74.     Input:"&Work Phone" Field:"Con->WorkPhone"
  75.       Row:10  Col:2  Wid:20
  76.     Input:"&Home Phone"  Field:"Con->Homephone"
  77.       Row:11  Col:2  Wid:20
  78.     Input:"Fax &Phone " Field:"Con->FaxPhone"
  79.       Row:12  Col:2  Wid:20
  80.     Input:"Birthda&y  " Field:"Con->BirthDay"
  81.       Row:13  Col:2  Wid:20
  82.     Input:"C&omment   "  Field:"Con->Comment"
  83.       Row:15  Col:2  Wid:50
  84.     Input:"&Last Name " Field:"Con->LastName"
  85.       Row:10  Col:35  Wid:14
  86.     Input:"Dear      " Field:"Con->Dear"
  87.       Row:11  Col:35  Wid:14
  88.     Input:"Zip Code  " Field:"Con->Zipcode"
  89.       Row:12  Col:35  Wid:14
  90.     Radio:"Fr&iend"
  91.       Check:"Con->Type=='Friend'"
  92.       Action:"Con->Type='Friend'"
  93.       UnAction:"Con->Type= Null"
  94.       Row:10  Col:62
  95.     Radio:"Fa&mily"
  96.       Check:"Con->Type=='Family'"
  97.       Action:"Con->Type='Family'"
  98.       UnAction:"Con->Type= Null"
  99.       Row:11  Col:62
  100.     Radio:"Clien&t"
  101.       Check:"Con->Type=='Client'"
  102.       Action:"Con->Type='Client'"
  103.       UnAction:"Con->Type= Null"
  104.       Row:12  Col:62
  105.     Radio:"&Vendor"
  106.       Check:"Con->Type=='Vendor'"
  107.       Action:"Con->Type='Vendor'"
  108.       UnAction:"Con->Type= Null"
  109.       Row:13  Col:62
  110.     HLine:"&Notes"
  111.       Row:16  Col:2  Len:1  Wid:76
  112.     Text:"" Field:"Con->Notes"
  113.       Row:17  Col:2  Len:4  Wid:76
  114.   Return (Ok)                         | That is all, Folks!
  115.  
  116. MailList:About
  117.   Msg:Add ("The JORF Mail List Manager", "Ok")
  118.     The JORF MailList Manager   Version 1.0     December 22, 1992
  119.  
  120.     Copyright (C) 1992 by Wayland Bruns, All Rights Reserved
  121.  
  122.     This program is a small version of the CONTACT.J contact manager. &
  123.     It features a name/address/phone number file, and limited &
  124.     label printing.  It does not support multiple files, filters &
  125.     and mail merge capability all found in CONTACT.J.
  126.  
  127.     Use this program as a base for new data base applications.  It &
  128.     is less complex than CONTACT.J but contains multiple keys, &
  129.     record locking and screen management functions needed by all &
  130.     data bases. For an even simpler example, see FILTER.J
  131.   Return (Ok)
  132.  
  133. MailList:Add(*Con)                 | Create a new record
  134.   | The key to creating a new record is to use the New function.
  135.   | The new function must be the first function used in a method.
  136.   | The new function is the only way in JORF to allocate memory
  137.   | and disk resources to create a new piece of data.
  138.   New (Contact:NewCon)            | Create and new empty maillist structure
  139.   NewCon->FullName = "New Record"  | Set a piece of data in it
  140.   Jorf:Write(NewCon)               | Write it to the correct file
  141.   Con = NewCon                      | And reset "Con" to point to our new one.
  142.   Win:Dsp                         | Redisplay everything
  143.   Kbd:Put("Alt_C_Key")            | Move the cursor to "Name"
  144.   Return(Ok)
  145.  
  146. MailList:Change()               | Change the current Con record
  147.   Kbd:Put("Alt_C_Key")          | stuff Alt_C to move the cursor to Name
  148.   Return(Ok)                    | That is all!
  149.  
  150. MailList:ContinLabels(Con,Flag)
  151.   New (Dest,Count,i)
  152.   Dest=Jorf:Printer()
  153.   If (Dest)
  154.     | Report format for Continuous labels, 6 lines per label, 1 line between
  155.     |
  156.     Rep:Add ("Continuous Labels")
  157.       Next:"MailList:Nextlabel(Con,Flag,Count)"
  158.       Item:"" NewRow:1 Col:26 Wid:12
  159.       Item:"Con->FullName"    NewRow:1 Col:1  Wid:40
  160.       Item:"Con->Company"     NewRow:1 Col:1  Wid:40
  161.         Before:"Con->Company!=Null"
  162.       Item:"Con->Addr1"       NewRow:1 Col:1  Wid:40
  163.       Item:"Con->Addr2"       NewRow:1 Col:1  Wid:40
  164.       Item:"Con->Addr3"       NewRow:1 Col:1  Wid:40
  165.       Item:"" NewRow:1
  166.         Before:"Con->Company==Null"
  167.  
  168.     | I like to append one blank label to advance the printer so I can
  169.     |  tear off the label just printed.
  170.     For (i=1 Thru 5)
  171.       File:Append("JREPORT.LST")
  172.  
  173.     | The Rep:Add function does not actually print, it just makes
  174.     | a report file called JREPORT.LST.  We can print this file
  175.     | using the File:Print function.
  176.     File:Print("JREPORT.LST",Dest,TRUE)
  177.   Return(Ok)
  178.  
  179. MailList:Delete(Con)             | Delete MailList Record
  180.   New (Result)
  181.  
  182.   | Pop up a nice screen to ask if they are sure
  183.   Result=Msg:Add('MailList Delete','No')
  184.     Delete this contact?
  185.  
  186.     Name:     {Bold:5}{Str:Pad(Con->FullName,30)}{Bold:0}
  187.     Company:  {Bold:5}{Str:Pad(Con->Company ,30)}{Bold:0}
  188.     Address : {Bold:5}{Str:Pad(Con->Addr1,30)}{Bold:0}
  189.               {Bold:5}{Str:Pad(Con->Addr2,30)}{Bold:0}
  190.               {Bold:5}{Str:Pad(Con->Addr3,30)}{Bold:0}
  191.  
  192.   | If they said "Yes", then Result will equal Ok (1)
  193.   If (Result==Ok)
  194.     Jorf:Del(Con)
  195.     Win:Dsp
  196.   Return (Ok)
  197.  
  198. MailList:KeySearch (*Con, Field)
  199.   New (Value,Prompt)
  200.  
  201.   Event:Add               | Block "MailKey" Events so Alt-C won't work
  202.   Switch (Field)
  203.     Case ("FullName")
  204.       Prompt="Name"
  205.     Case ("Company")
  206.       Prompt="Company"
  207.     Case ("WorkPhone")
  208.       Prompt="Phone"
  209.     Case ("LastName")
  210.       Prompt="Last Name"
  211.     Case ("ZipCode")
  212.       Prompt="Zip Code"
  213.     Else
  214.       Msg:Add
  215.         Unknown Field {Field}
  216.       Return (Ok)
  217.  
  218.   Win:Add ("Key Search", 10, 15, 6, 60, Here)
  219.     Input:"Search for {Prompt}", Row: 2 Col:5 Wid:30, Field:"Value"
  220.     Button:"&Search"  Row:4 Col:5  Wid:20 Action:"Return (Null)"
  221.     B